package WaiBao;

import java.util.Arrays;

public class DuMingFeng {
    public static void main(String[] args) {
        String[] name = {"张大伟(班长)", "李小伟(副班长)", "小李(学习委员)", "王胖子(团支书)", "马磊", "叶少良", "王麻子", "钟意", "贾德佳", "李戴", "胡慧珍", "文君",
                "王自强", "何国秀", "田文澜", "何炅", "将华宇", "刘梅", "李佳薇", "李晓梅", "杜小兰", "李小春", "李静瑶", "胡橘芳", "王波", "刘佳", "沈霞", "彭海燕",
                "王嘉尔", "杜明凤(学生)"};//考生本人:杜明凤(学生)
        int[] age = {21, 19, 17, 18,20, 19, 20, 20, 19, 19,21, 20, 18, 20, 20, 19, 20, 20, 18, 18, 20, 19, 21, 20, 20, 18, 19, 19, 18,19};//考生年龄：19岁

        double[] kangyuan1 = {81, 80, 86, 78, 78, 67, 78, 85, 81, 84, 91, 71, 85, 76, 65, 68, 99, 99, 96, 78, 92, 91, 95, 65, 75, 74, 83, 78, 81, 95};
        double[] kangyuan2 = {76, 87, 78, 84, 74, 77, 81, 64, 88, 77, 85, 74, 72, 85, 64, 75, 76, 90, 66, 98, 72, 71, 55, 86, 78, 88, 84, 83, 88, 91};
        double[] kangyuan3 = {77, 77, 83, 85, 75, 69, 78, 69, 80, 80, 83, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 82, 78, 79, 87, 96};

        double luyou1;//代表每个学生的总分
        double luyou2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            luyou1 =kangyuan1[i] + kangyuan2[i] + kangyuan3[i];
//            luyou2= (luyou1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + luyou1);
//            System.out.println(name[i] + "的平均分为:" +luyou2);
//        }

        double cuo1 = 0,cuo2 = 0;
        double[]  dui = new double[30];
//        for (int i = 0; i < 30; i++) {
//            cuo1=kangyuan1[i] +kangyuan2[i] + kangyuan3[i];
//            cuo2 = (cuo1* 1.0) / 3;
//            dui[i] = cuo2;
//        }
//
//        for (int i = 0; i < dui.length - 1; i++) {
//            for (int j = 0; j <dui.length - i - 1; j++) {
//                if (dui[j] <dui[j + 1]) {
//                    double tep =dui[j];
//                    dui[j] =dui[j + 1];
//                    dui[j + 1] = tep;
//                }
//            }
//        }
//
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(dui[i]);
//        }


        double chayu1 = 0,chayu2 = 0,chayu3 = 0;//计算每门课的平均分
        double sanliu1 = 0,sanliu2 = 0,sanliu3 = 0;//计算每门课标准差
        double laoji1 = 0,laoji2 = 0, laoji3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < kangyuan1.length; i++) {
            he +=kangyuan1[i];
        }
        chayu1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" +chayu1);
        double Sum = 0;
        for (int i = 0; i < kangyuan2.length; i++) {
            Sum += kangyuan2[i];
        }
        chayu2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" +chayu2);
        double sum = 0;
        for (int i = 0; i < kangyuan3.length; i++) {
            sum +=kangyuan3[i];
        }
        chayu3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + chayu3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < kangyuan1.length; i++) {
            c1 += (kangyuan1[i] - chayu1) * (kangyuan1[i] -chayu1);
        }
        sanliu1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" +sanliu1);
        for (int i = 0; i <kangyuan2.length; i++) {
            c2 += (kangyuan2[i] -chayu2) * (kangyuan2[i] -chayu2);
        }
        sanliu2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +sanliu2);

        for (int i = 0; i <kangyuan3.length; i++) {
            c3 += (kangyuan3[i] - chayu3) * (kangyuan3[i] -chayu3);
        }
        sanliu3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" +sanliu3);
//////////
        Arrays.sort(kangyuan1);
        Arrays.sort(kangyuan2);
        Arrays.sort(kangyuan3);
        laoji1 = (kangyuan1[15] + kangyuan1[14]) * 1.0 / 2;
        laoji2 = (kangyuan2[15] +kangyuan2[14]) * 1.0 / 2;
        laoji3 = (kangyuan3[15] +kangyuan3[14]) * 1.0 / 2;
        System.out.println("农业设施及环境调控的中位数为:" + laoji1);
        System.out.println("农业设施设计与制造的中位数为:" + laoji2);
        System.out.println("园艺植物设施栽培学的中位数为:" + laoji3);




    }
}
